<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>物资盘点</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<t:base type="bootstrap,bootstrap-table,layer,validform,bootstrap-form"></t:base>
</head>
 <body style="overflow:hidden;overflow-y:auto;">
 <div class="container" style="width:100%;">
	<div class="panel-heading"></div>
	<div class="panel-body">
	<form class="form-horizontal" role="form" id="formobj" action="wzSupplyCheckController.do?doAdd" method="POST">
		<input type="hidden" id="btn_sub" class="btn_sub"/>
		<input type="hidden" id="id" name="id"/>
		<div class="form-group">
			<label for="supplyId" class="col-sm-3 control-label">物资名称：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<input id="supplyId" name="supplyId" type="hidden"/>
					<input id="supplyName" name="supplyName" readonly="readonly" type="text" class="form-control input-sm" placeholder="请输入物资名称" style='width:360px' />
					<t:choose hiddenName="supplyId" hiddenid="id" url="wzSupplyController.do?pop"
						 name="wzSupplyList" icon="icon-search" title="选择物资" textname="name" 
						fun="setQty" inputTextname="supplyName" width="710px" isInit="true"></t:choose>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="supplySn" class="col-sm-3 control-label">物资编号：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<input id="supplySn" readonly="readonly" name="supplySn" type="text" maxlength="30" class="form-control input-sm" placeholder="请输入物资编号"  ignore="ignore" />
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="qty" class="col-sm-3 control-label">系统库存：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<input id="qty" name="qty" type="text" readonly="readonly" class="form-control input-sm" placeholder="请输入系统库存"  datatype="/^(-?\d+)(\.\d+)?$/"  ignore="ignore" />
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="realQty" class="col-sm-3 control-label">实际库存：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<input id="realQty" name="realQty" type="number" maxlength="32" class="form-control input-sm" placeholder="请输入实际库存"  datatype="/^(-?\d+)(\.\d+)?$/"  ignore="ignore" />
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="offsetNumber" class="col-sm-3 control-label">偏差数量：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<input id="offsetNumber" name="offsetNumber" readonly="readonly" type="number" maxlength="50" class="form-control input-sm" placeholder="请输入偏差数量"  datatype="/^(-?\d+)(\.\d+)?$/"  ignore="ignore" />
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="offsetNumber" class="col-sm-3 control-label">处理结果：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<t:dictSelect id="dealResult" field="dealResult" typeGroupCode="dealresult" title="处理结果"></t:dictSelect>
				</div>
			</div>
		</div>
		
		<div class="form-group">
			<label for="keepState" class="col-sm-3 control-label">保养状况：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<t:dictSelect id="keepState" field="keepState" defaultVal="1" typeGroupCode="keep_state" title="保养状况"></t:dictSelect>
				</div>
			</div>
		</div>
		
		<div class="form-group">
			<label for="creatorId" class="col-sm-3 control-label">盘点人：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
					<input id="creatorId" name="creatorId" type="hidden" value="${wzSupplyCheckPage.creatorId }"/>
					<input id="creatorName" name="creatorName" readonly="readonly" type="text" maxlength="36" class="form-control input-sm" value="${creatorName }"  ignore="ignore" />
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="checkDate" class="col-sm-3 control-label">盘点日期：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
				<input name="checkDate" type="text" value="${today }" class="form-control laydate-date"  ignore="ignore"  />
				<span class="input-group-addon" ><span class="glyphicon glyphicon-calendar"></span></span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label for="createDate" class="col-sm-3 control-label">登记日期：</label>
			<div class="col-sm-7">
				<div class="input-group" style="width:100%">
				<input name="createDate" type="text" class="form-control" readonly="readonly" ignore="ignore" value="${today }" />
				<span class="input-group-addon" ><span class="glyphicon glyphicon-calendar"></span></span>
				</div>
			</div>
		</div>
		
	</form>
	</div>
 </div>
<script type="text/javascript">
var subDlgIndex = '';
function setQty(){
	$.ajax({
		url:"<c:url value="/wzSupplyController.do?getById"/>",
		data:{id:$('#supplyId').val()},
		type:'post',
		dataType:'json',
		success:function(ret){
			$('#qty').val(ret.attributes.qty);
			$('#supplySn').val(ret.attributes.sn);
		}
	})
}
function accAdd(arg1,arg2){ 
	var r1,r2,m;  
	try{
	r1=arg1.toString().split(".")[1].length
	}catch(e){
	r1=0}  try{
	r2=arg2.toString().split(".")[1].length}catch(e){r2=0}  m=Math.pow(10,Math.max(r1,r2))  
	return (arg1*m+arg2*m)/m
}
$(document).ready(function() {
	$('#realQty').blur(function(e){
		var qty = $('#qty').val();
		var realQty = $('#realQty').val();
		var num = accAdd(qty,"-"+realQty);
		$('#offsetNumber').val(num);
		if(num==0){
			$('#dealResult').val(1);
		}else{
			$('#dealResult').val(5);
		}
	})
	$(".laydate-datetime").each(function(){
		var _this = this;
		laydate.render({
		  elem: this,
		  format: 'yyyy-MM-dd HH:mm:ss',
		  type: 'datetime'
		});
	});
	$(".laydate-date").each(function(){
		var _this = this;
		laydate.render({
		  elem: this
		});
	});
	//单选框/多选框初始化
	$('.i-checks').iCheck({
		labelHover : false,
		cursor : true,
		checkboxClass : 'icheckbox_square-green',
		radioClass : 'iradio_square-green',
		increaseArea : '20%'
	});
	
	//表单提交
	$("#formobj").Validform({
		tiptype:function(msg,o,cssctl){
			if(o.type==3){
				validationMessage(o.obj,msg);
			}else{
				removeMessage(o.obj);
			}
		},
		btnSubmit : "#btn_sub",
		btnReset : "#btn_reset",
		ajaxPost : true,
		beforeSubmit : function(curform) {
		},
		usePlugin : {
			passwordstrength : {
				minLen : 6,
				maxLen : 18,
				trigger : function(obj, error) {
					if (error) {
						obj.parent().next().find(".Validform_checktip").show();
						obj.find(".passwordStrength").hide();
					} else {
						$(".passwordStrength").show();
						obj.parent().next().find(".Validform_checktip").hide();
					}
				}
			}
		},
		callback : function(data) {
			var win = frameElement.api.opener;
			if (data.success == true) {
				frameElement.api.close();
			    win.reloadTable();
			    win.tip(data.msg);
			} else {
			    if (data.responseText == '' || data.responseText == undefined) {
			        $.messager.alert('错误', data.msg);
			        $.Hidemsg();
			    } else {
			        try {
			            var emsg = data.responseText.substring(data.responseText.indexOf('错误描述'), data.responseText.indexOf('错误信息'));
			            $.messager.alert('错误', emsg);
			            $.Hidemsg();
			        } catch (ex) {
			            $.messager.alert('错误', data.responseText + "");
			            $.Hidemsg();
			        }
			    }
			    return false;
			}
		}
	});
		
});
</script>
</body>
</html>